package com.ji.li.reactadminproexampleservice.utils.type;

import com.ji.li.reactadminproexampleservice.constants.SecurityConstants;
import com.ji.li.reactadminproexampleservice.entity.user.User;
import com.ji.li.reactadminproexampleservice.utils.Utils;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.security.Keys;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import javax.crypto.SecretKey;
import javax.xml.bind.DatatypeConverter;
import java.util.List;

/**
 * @author ji.li
 * jwt 相关 工具类 接口
 */
public interface JwtUtils extends Utils {
    /**
     * 生成足够的安全随机密钥，以适合符合规范的签名
     * */
   static final byte[] API_KEY_SECRET_BYTES = DatatypeConverter.parseBase64Binary(SecurityConstants.JWT_SECRET_KEY);
   static final SecretKey SECRET_KEY = Keys.hmacShaKeyFor(API_KEY_SECRET_BYTES);
    /**
     * rememberMe 为 false 的时候过期时间是1个小时
     */
    static final long EXPIRATION = 60 * 60L;

    /**
     * rememberMe 为 true 的时候过期时间是7天
     */
    static final long EXPIRATION_REMEMBER = 60 * 60 * 24 * 7L;

   public String createToken(String username, int id, List<String> roles, boolean isRememberMe);
   public String getU_id(String token);
    public UsernamePasswordAuthenticationToken getAuthentication(String token);
}
